#pragma once 

#include <vector>

struct RawPixel
{
	unsigned char r, g, b;

	RawPixel() : r(0), g(0), b(0) {}

	RawPixel(unsigned char R, unsigned char G, unsigned char B)
	{
		r = R;
		g = G;
		b = B;
	}

	bool operator == (RawPixel & other)	{
		return (r == other.r) && (g == other.g) && (b == other.b);
	}
	bool operator != (RawPixel & other)	{
		return (r != other.r) || (g != other.g) || (b != other.b);
	}
};

struct HSV
{
	unsigned char h, s, v;

	HSV() : h(0), s(0), v(0) {}

	HSV(unsigned char H, unsigned char S, unsigned char V)
	{
		h = H;
		s = S;
		v = V;
	}
};

struct Filter
{
	HSV top, bottom;

	Filter(HSV& t, HSV& b)
	{
		top = t;
		bottom = b;
	}

	bool check(HSV& pixel)
	{
		if( 
			(pixel.h < top.h) && (pixel.h > bottom.h) &&
			(pixel.s < top.s) && (pixel.s > bottom.s) &&
			(pixel.v < top.v) && (pixel.v > bottom.v)
			)
			return true;
		return false;
	}
};

class Object
{
public:
	RawPixel id;
	std::vector< Filter > filters;

	Object(RawPixel& myid)
	{
		id = myid;
	}

	void add_filter(Filter & filter)
	{
		filters.push_back(filter);
	}

	bool check(HSV& pixel)
	{
		for(unsigned int filter_index=0; filter_index < filters.size(); filter_index++)
		{
			Filter & filter = filters[filter_index];
			if( filter.check(pixel) ) return true;
		}
		return false;
	}
};

struct MouseEvent
{
	int triggered;
	int event, x, y, flags;
	RawPixel pixel;
	HSV converted;

	MouseEvent() : triggered(0), x(0), y(0), flags(0) {}
	MouseEvent(int event_, int x_, int y_, int flags_, 
		unsigned char r, unsigned char g, unsigned char b,
		unsigned char h, unsigned char s, unsigned char v)
	{
		triggered = 1;
		event = event_;
		x = x_;
		y = y_;
		flags = flags_;
		pixel.r = r;
		pixel.g = g;
		pixel.b = b;
	}
};

struct CameraResult
{
	double operation_interval;
	int status;
	int x, y;
	CameraResult() : operation_interval(0), status(0), x(0), y(0) {}
};





